import { isObject } from "lodash-es";

/**
 * @description 是否为空对象
 * @param {Object} value
 * @return {Boolean}
 */
export const isEmptyObject = (target: object) => {
    return target?(isObject(target) && !Object.keys(target).length):true;
};

/**
 * 手机号去除敏感词
 */
export function mobileConceal(mobile: string): string {
    return mobile.substring(0, 3) + "****" + mobile.substr(mobile.length - 4);
}

/**
 * 验证电子邮箱格式
 * @param value
 * @returns
 */
export function isEmail(value: string) {
    return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(
        value
    );
}

/**
 * 验证手机格式
 * @param value
 * @returns
 */
export function isMobile(value: string) {
    return /^1[23456o789]\d{9}$/.test(value);
}
